<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <style>
        html,
        body,
        #mapui {
            margin: 0 auto;
            width: 100%;
            height: 100%
        }

        html,
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
        }
    </style>

</head>

<body>
    <div id="mapui"></div>

    <script src="./js_thematic_map_example/script/jq/jquery.min.js"></script>
    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>

    <script>
        var echartsLayer = null;
        var option = null;
        var amap = null;
        var that = this;

        var uploadedDataURL = "./js_thematic_map_example/data/lines-bus.json";

        $.get(uploadedDataURL, function (data) {
            var busLines = [].concat.apply([], data.map(function (busLine, idx) {
                var prevPt;
                var points = [];
                for (var i = 0; i < busLine.length; i += 2) {
                    var pt = [busLine[i], busLine[i + 1]];
                    if (i > 0) {
                        pt = [
                            prevPt[0] + pt[0],
                            prevPt[1] + pt[1]
                        ];
                    }
                    prevPt = pt;

                    points.push([pt[0] / 1e4, pt[1] / 1e4]);
                }
                return {
                    coords: points
                };
            }));

            option = {
                GLMap: {
                    roam: true
                },
                coordinateSystem: 'GLMap',

                series: [{
                    type: 'lines',
                    coordinateSystem: 'GLMap',
                    polyline: true,
                    data: busLines,
                    silent: true,
                    lineStyle: {
                        normal: {
                            color: 'rgb(200, 35, 45)',
                            opacity: 0.2,
                            width: 1
                        }
                    },
                    progressiveThreshold: 500,
                    progressive: 200
                }]
            };


            map.Factory.create('mapui', {
                center: [116.5, 39.8],
                fullExtent: {
                    xmin: 90.992204,
                    ymin: 10.979711,
                    xmax: 120.5338915,
                    ymax: 50.543712
                },
                zoom: 8,
                projection: 'EPSG:4326',
                strategy: ['mapboxgl', 'openlayers'],
                style: style
            }, (o) => {
                amap = o;
                map.Factory.loadSpecialMap('echarts', () => {
                    that.init(amap.pmap);
                })
            });
        });

        function init(map) {
            echartsLayer = new EchartsLayer(map);
            echartsLayer.chart.setOption(option);
        }



    </script>
</body>

</html>